package org.jeecg.modules.bobo.desform.service.impl;

import org.jeecg.modules.bobo.desform.entity.LbDesform;
import org.jeecg.modules.bobo.desform.entity.LbDesformData;
import org.jeecg.modules.bobo.desform.mapper.LbDesformDataMapper;
import org.jeecg.modules.bobo.desform.mapper.LbDesformMapper;
import org.jeecg.modules.bobo.desform.service.ILbDesformService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 动态表单
 * @Author: jeecg-boot
 * @Date:   2021-04-09
 * @Version: V1.0
 */
@Service
public class LbDesformServiceImpl extends ServiceImpl<LbDesformMapper, LbDesform> implements ILbDesformService {

	@Autowired
	private LbDesformMapper lbDesformMapper;
	@Autowired
	private LbDesformDataMapper lbDesformDataMapper;
	
	@Override
	@Transactional
	public void delMain(String id) {
		lbDesformDataMapper.deleteByMainId(id);
		lbDesformMapper.deleteById(id);
	}

	@Override
	@Transactional
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			lbDesformDataMapper.deleteByMainId(id.toString());
			lbDesformMapper.deleteById(id);
		}
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public boolean saveLbDesform(LbDesform lbDesform) {
		boolean b = save(lbDesform);
//		if ("1".equals(lbDesform.getStatus())){
//			lbDesformMapper.setNoQiyong(lbDesform.getId(),lbDesform.getDesformType());
//		}
		return b;
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public boolean updateLbDesformById(LbDesform lbDesform) {
//		if ("1".equals(lbDesform.getStatus())){
//			lbDesformMapper.setNoQiyong(lbDesform.getId(),lbDesform.getDesformType());
//		}
		return updateById(lbDesform);
	}

}
